package com.campus.controller;

import com.campus.common.Result;
import com.campus.entity.LostItems;
import com.campus.service.LostItemService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class LostItemsController {
    @Autowired
    private LostItemService lostItemService;
    /**
     * 失物招领发布帖子
     */
    @PostMapping("/lost-found/create")
    public Result createLostItem(@RequestBody LostItems lostItems, HttpServletRequest request){
        Result result = lostItemService.createLostItem(lostItems, request);
        return result;
    }

    /**
     *
     * @param page 页数
     * @param size 条数
     * @param type 类型 LOST寻物，FOUND招领
     * @param status 状态 OPEN进行中，RESOLVE已解决，CLOSED已解决
     * @param keyword
     * @param request
     * @return
     */
    @GetMapping("/lost-found/list")
    public Result getLostItems(@RequestParam(defaultValue = "1") Integer page,
                              @RequestParam(defaultValue = "10") Integer size,
                              @RequestParam(required = false) String type,
                              @RequestParam(required = false) String status,
                              @RequestParam(required = false) String keyword,
                              HttpServletRequest request){
        Result result = lostItemService.getItemsList(page, size, type, status, keyword, request);
        return result;
    }
}